package 注解;

import java.lang.reflect.Method;

/**
 * @author zc
 * @version 1.0
 * @date 2021/9/23 16:30
 */
public class MyTargetTest {

    @MyTarget
    public void doSomething(){
        System.out.println("hhhh");
    }

    public static void main(String[] args) throws NoSuchMethodException {
        Method method = MyTargetTest.class.getMethod("doSomething", null);
        if(method.isAnnotationPresent(MyTarget.class)){//如果doSomething方法上存在注解@MyTarget，则为true
            System.out.println("true=======>"+method.getAnnotation(MyTarget.class));
        }
    }
}
